package cn.amossun.starter.event.handler;

import cn.hutool.core.util.StrUtil;
import cn.amossun.starter.event.annoation.EventPublisher;
import cn.amossun.starter.event.property.EventQueueContext;

public interface QueueContextHolder extends EventContextHolder {

    default EventQueueContext buildEventQueueContexts(EventPublisher eventPublisher) {
        if(eventPublisher.binding() != null && StrUtil.isNotEmpty(eventPublisher.binding().key())
                && eventPublisher.binding().queue() != null && StrUtil.isNotEmpty(eventPublisher.binding().queue().name()) && StrUtil.isNotEmpty(eventPublisher.binding().queue().value())) {
            return process(eventPublisher.binding().queue());
        }
        return null;
    }

}
